<!DOCTYPE html>
<html lang="zh">
<head>
    <meta charset="UTF-8">
    <title>webSocket</title>
</head>
<body>
<h1>webSocket</h1>

</body>
</html>
<script>
    ws = new WebSocket("ws://192.168.122.130:9999");
    ws.onopen = function () {
        // Web Socket 已连接上，使用 send() 方法发送数据
        ws.send("发送数据");
    }
    ws.onmessage = function (evt)
    {
       console.log("=====onmessage====",evt.data);
    };
    ws.onclose = function()
    {
        // 关闭 websocket
        console.log("连接已关闭...");
    };
</script>